package com.example.springevent.common;

public class CommonResponse<T> {
	
	public static String CODE_SUCCESS = "00000";
	public static String CODE_FAIL = "99999";

	private String code;
	private String msg;
	private T data;

	public CommonResponse(String code, String msg, T data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}

	public static CommonResponse success() {
		return new CommonResponse(CODE_SUCCESS, null, null);
	}

	public static CommonResponse success(Object obj) {
		return new CommonResponse(CODE_SUCCESS, null, obj);
	}

	public static CommonResponse fail() {
		return new CommonResponse(CODE_FAIL, null, null);
	}

	public static CommonResponse fail(String code, String msg) {
		return new CommonResponse(code, msg, null);
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getData() {
		return data;
	}

	public void setData(T data) {
		this.data = data;
	}

}
